<?php 
session_start();
if (isset($_POST['name']) && isset($_POST['fdes'])){
    $openid=trim(addslashes($_POST['fdes']));
	$name=trim(addslashes($_POST['name']));
	$phone=trim(addslashes($_POST['phone']));
	$nianji=trim(addslashes($_POST['nianji']));
	$card=trim(addslashes($_POST['card']));
	$qu=trim(addslashes($_POST['qu']));
	$school=trim(addslashes($_POST['school']));
	
	if (empty($name) || empty($phone) || empty($nianji)){
	    echo json_encode(array('s'=>'not','msg'=>'empty'));
	    exit;
	}
	include_once("../c/config.php");
	$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
	if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqliTwo->error);}
	
	$thisTable=getU3Table($nianji);
	
	$sql="select id from ".$thisTable." where openid='".$openid."'  limit 0, 1";
	$query=$mysqli->query($sql);
    if($query->num_rows>0){
        echo json_encode(array('s'=>'ok'));
    }else{
        $mysqli->query("insert into ".$thisTable."(openid,name,phone,nianji,idcard,qu,school,createtime) 
values('".$openid."','".$name."','".$phone."','".$nianji."','".$card."','".$qu."','".$school."','".date("Y-m-d H:i:s")."') ");
        $mysqli->query("insert into idcheck(openid,nianji) values('".$openid."','".$nianji."')");
        echo json_encode(array('s'=>'ok'));
    }
    $mysqli->close();
}else{
    echo json_encode(array('s'=>'not'));
}
?>